package com.yaowk.web.mall.clothing.controller;

import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import com.yaowk.api.mall.clothing.model.MemberGroup;
import com.yaowk.api.mall.clothing.service.IMemberGroupService;
import com.yaowk.api.mall.clothing.web.MemberGroupModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by yaowk on 17-10-20.
 */
@RestController
@RequestMapping("/mall/clothing/memberGroup")
@Api(tags = "会员组")
public class MemberGroupController {

    @Autowired
    private IMemberGroupService memberGroupService;

    @ApiOperation("查询会员组列表")
    @GetMapping
    public PageResp<MemberGroupModel> list(PageReq pageReq) {
        PageResp<MemberGroupModel> page = memberGroupService.findAllOfWeb(pageReq);
        return page;
    }


    @ApiOperation("保存会员组信息")
    @PostMapping
    public MemberGroup save(MemberGroup memberGroup) {
        memberGroup = memberGroupService.save(memberGroup);
        return memberGroup;
    }

    @ApiOperation("根据id删除会员组信息")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id) {
        memberGroupService.deleteById(id);
        return;
    }

    @GetMapping("/{id}")
    @ApiOperation("查询会员组详情")
    public MemberGroup member(@PathVariable Integer id) {
        MemberGroup memberGroup = memberGroupService.findById(id);
        return memberGroup;
    }
}
